﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using nERP.Model.So;
using nERP.Model;

using nERP.Model.So;
using nERP.Model.Bas;
using nERP.Model.Wms;


namespace nERP.ViewModel.So.SaleReturnDetailVMs
{
    public partial class SaleReturnDetailSaleReturnDetailListVM3 : BasePagedListVM<SaleReturnDetail, SaleReturnDetailDetailSearcher3>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
            };
        }
 
        protected override IEnumerable<IGridColumn<SaleReturnDetail>> InitGridHeader()
        {
            return new List<GridColumn<SaleReturnDetail>>{
                
                this.MakeGridHeader(x => x.ID).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.ID"].Value),
                this.MakeGridHeader(x => x.CreateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.UpdateTime).SetEditType(EditTypeEnum.Datetime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.CreateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.UpdateBy).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.UpdateBy"].Value),
                this.MakeGridHeader(x => x.TenantCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Tenant"].Value),
                this.MakeGridHeader(x => x.Seq).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.序号"].Value),
                this.MakeGridHeader(x => x.SaleReturnDetailCode).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.退货明细单号"].Value),
                this.MakeGridHeader(x => x.SaleOutWarehouseDetailId).SetEditType(EditTypeEnum.ComboBox,DC.Set<SaleOutWarehouseDetail>().GetSelectListItems(Wtm, x => x.SaleOutWarehouseDetailCode, x => x.SaleOutWarehouseDetailCode,SortByName:true)).SetTitle(@Localizer["Page.销售出库明细"].Value),
                this.MakeGridHeader(x => x.SaleId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Sale>().GetSelectListItems(Wtm, x => x.SaleCode, x => x.SaleCode,SortByName:true)).SetTitle(@Localizer["Page.销售订单"].Value),
                this.MakeGridHeader(x => x.SaleDetailId).SetEditType(EditTypeEnum.ComboBox,DC.Set<SaleDetail>().GetSelectListItems(Wtm, x => x.SaleDetailCode, x => x.SaleDetailCode,SortByName:true)).SetTitle(@Localizer["Page.销售明细"].Value),
                this.MakeGridHeader(x => x.GoodsId).SetEditType(EditTypeEnum.ComboBox,DC.Set<Goods>().GetSelectListItems(Wtm, x => x.GoodsName, x => x.GoodsCode,SortByName:true)).SetTitle(@Localizer["Page.商品"].Value),
                this.MakeGridHeader(x => x.GoodsName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.商品名称"].Value),
                this.MakeGridHeader(x => x.GoodsSpec).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.商品规格"].Value),
                this.MakeGridHeader(x => x.GoodsUnit).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.计量单位"].Value),
                this.MakeGridHeader(x => x.ReturnNumber).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.退货数量"].Value),
                this.MakeGridHeader(x => x.UnitPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.退货单价"].Value),
                this.MakeGridHeader(x => x.DiscountPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.折扣金额"].Value),
                this.MakeGridHeader(x => x.TotalPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.退货金额"].Value),
                this.MakeGridHeader(x => x.TaxRate).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.税率"].Value),
                this.MakeGridHeader(x => x.TaxUnitPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.含税单价"].Value),
                this.MakeGridHeader(x => x.TaxPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.税额"].Value),
                this.MakeGridHeader(x => x.TotalTaxPrice).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.含税金额"].Value),
                this.MakeGridHeader(x => x.Remark).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["_Admin.Remark"].Value),
                this.MakeGridHeader(x => x.Status).SetEditType(EditTypeEnum.ComboBox,typeof(dStatusTypeEnum).ToListItems(null,true)).SetTitle(@Localizer["Page.状态"].Value),

            };
        }

        
        public override IOrderedQueryable<SaleReturnDetail> GetSearchQuery()
        {
                
            var id = (string)Searcher.SaleReturnId.ConvertValue(typeof(string));
            if (id == null)
                return new List<SaleReturnDetail>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<SaleReturnDetail>()
                .Where(x => id == x.SaleReturnId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class SaleReturnDetailDetailSearcher3 : BaseSearcher
    {
        
        [Display(Name = "_Model._SaleReturnDetail._SaleReturn")]
        public string SaleReturnId { get; set; }
    }

}

